<?php

include("../lib/db.lib");
include("../lib/std.lib");

$title=cat_get_title($shop_id,$cat_id);

$cat_chain[]="Latest One";
$latest_cat_id=cat_check($cat_chain,1);

$uip=$_SERVER["REMOTE_HOST"];
if(!$uip) 
$uip=$_SERVER["REMOTE_ADDR"];

$uname=param("user_name");

$pdlist=cat_pd_list($shop_id,$latest_cat_id);

foreach($pdlist as $val){

	if(preg_match("/package/",$val['id'],$m)) break;

	$url="http://www.xys.org/xys/".$val['id'];
	$url_split=preg_split("/\//",$url);
	$cat_chain=$url_split;
	array_shift($cat_chain); array_shift($cat_chain); array_shift($cat_chain);
	$num=count($cat_chain);
	$cat_chain[$num-1] = preg_replace('/([0-9]*).txt/',"",$cat_chain[$num-1]);
	$cat_chain[0]="Topics";

	$cid=cat_check($cat_chain,1);

	$val=$cid;	
	$list[$val]['alias']=$_POST["cat_alias_${val}"];

}

foreach($list as $key=>$val){
	setcookie("cat_alias_${key}",$val['alias']);
	xys_cat_add($key,$val['alias'],$uname,$uip);
	
	system("echo  '".date("F j, Y, g:i a")." ". $uip. " Update cat alias: Catid $key,".$val['alias']."'>>./parse/sys_log.txt");
	

}
foreach($list as $key=>$val){

}

redirect("Thanks for your cooperation!","index.php",1);

?>
